<template>
	<div>
		<div>
			<el-input
				style="width: 300px; margin-right: 10px; margin-left: -500px;"
				clearable
				@clear="initExit"
				v-model="name"
				@keydown.enter.native="initExit"
			    placeholder="请输入姓名进行搜索"
			    prefix-icon="el-icon-search">
			</el-input>
			<el-button type="primary" @click="initExit">搜索</el-button>
			<el-button type="primary" @click="showExitAdd">添加</el-button>
		</div>
		<div>
			<el-table
		  :data="tableData"
			
			
		  style="width: 100%">
		   <el-table-column
		          prop="patientId"
		          label="序号"
		          >
		        </el-table-column>
		        <el-table-column
		          prop="patient.name"
		          label="姓名"
		          >
		        </el-table-column>
		        <el-table-column
		          prop="patient.sex"
		          label="性别">
		        </el-table-column>
				   <el-table-column
		      prop="patient.age"
		      label="年龄"
		      >
		    </el-table-column>
		    <el-table-column
		      prop="patient.indate"
		      label="入住时间"
		      >
		    </el-table-column>
		    <el-table-column
		      prop="patient.outdate"
		      label="退住时间">
		    </el-table-column>
			   <el-table-column
		      prop="exitType"
		      label="退住类型"
		      >
		    </el-table-column>
		    <el-table-column
		      prop="exitReason"
		      label="退住原因"
		      >
		    </el-table-column>
		 
			   
		    <el-table-column
		      prop="applyTime"
		      label="申请时间"
		      >
		    </el-table-column>
		   
			</el-table-column>
			<el-table-column
			  prop="remarks"
			  label="备注"
			  >
			</el-table-column>
			  
			 
			  
		  <el-table-column label="操作">
		    <template slot-scope="scope">
		     <el-button @click="showExitEdit(scope.row)">编辑</el-button>
		     	<el-button @click="deleteExit(scope.row)" type="danger">删除</el-button>    
		    </template>
		  </el-table-column>
		</el-table>
		<el-pagination
			    background
				@current-change="currentChange"
			    layout="prev, pager, next,jumper,->,total"
			    :total=total>
			  </el-pagination>
		</div>
		 <el-dialog title="退住信息添加" :visible.sync="dialogVisible">
		 	<ExitAdd  :dialogVisible.sync=dialogVisible @add="initExit()"></ExitAdd>
		 </el-dialog>
		 <el-dialog title="退住信息编辑" :visible.sync="editVisible">
		  			<ExitEdit :editVisible.sync="editVisible" :formData="formData"></ExitEdit>
		  		</el-dialog>
		</div>
		
		
		
	
</template>

<script>
	import ExitAdd from './exit_add.vue'
	import ExitEdit from './exit_edit.vue'
  export default {
	  
	  name: "exit",
	  components:{
	  	ExitAdd,
		ExitEdit
	  },
	
    data(){
      return {
		  
		 
				  tableData:[],
				  total:0,
				  currentPage:1,
				  size:10,
				  name:'',
				  dialogVisible:false,
				  editVisible:false,
				  formData:{
				  	patientId:'',
				  	outReason:'',
				  	outTime:'',
				  	returnTime:'',
				  	compay:'',
				  	relationtelphone:'',
				  	realTime:''
				  }
			  
		  }
		  
        
      },
	  
    
	mounted(){
		 this.initExit();
	},
    methods: {
		showExitEdit(data){
						this.editVisible=true;
						this.formData=data;
						// console.log("父组件数据:");
						// console.log(this.formData)
					},
		deleteExit(data){
						this.$confirm('此操作将永久删除'+data.patientId+'号病人的康复计划，是否继续？','提示',{
							confirmButtonText:'确定',
							cancelButtonText:'取消',
							type:'warning'
						}).then(() => {
							this.getRequest('/exit-registrate/delete?patientId='+data.patientId).then(resp =>{
								if(resp){
									this.initExit();
								}
							})
						}).catch(() => {
							this.$message({
								type:'info',
								message:'已取消删除'
							});
						});
					},
		currentChange(currentPage){
			this.currentPage=currentPage;
			this.initExit();
		},
		showExitAdd(){
			this.dialogVisible=true
		},
		initExit(){
			this.getRequest('/exit-registrate/planList?currentPage='+this.currentPage+'&size='+this.size+'&patient.name='+this.name).then(resp=>{
				if(resp){         
					this.tableData=resp.data;
					this.total=resp.total;
				}
			})
		}
      
      }
    }
  
</script>

<style>
</style>
